a tool for shared writing and social publishing
1export type ActionAfterSignIn = {
2 action: "subscribe";
3 publication: string;
4};
5
6export function encodeActionToSearchParam(actions: ActionAfterSignIn): string {
7 return encodeURIComponent(JSON.stringify(actions));
8}
9
10export function parseActionFromSearchParam(
11 param: string | null,
12): ActionAfterSignIn | null {
13 if (!param) return null;
14 try {
15 return JSON.parse(decodeURIComponent(param)) as ActionAfterSignIn;
16 } catch {
17 return null;
18 }
19}